﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace BigInteger
{
    class Util
    {
        public static List<int> Digitize(int value)
        {
            var result = new List<int>();
            while (value > 0)
            {
                result.Add(value % 10);
                value /= 10;
            }
            return result;
        }

        public static Integer Evaluate(string s)
        {
            if (s.Contains("^"))
            {
                var tokens = s.Split(new[] {'^'}, StringSplitOptions.RemoveEmptyEntries);
                var number = new Integer(tokens[0]);
                var exponent = int.Parse(tokens[1]);
                return number.Power(exponent);
            }
            else if (s.Contains("!"))
            {
                return null;
            }
            else
            {
                return new Integer(s);
            }
        }
    }
}
